<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Fabrice
 * Date: 21/02/14
 * Time: 19:31
 * To change this template use File | Settings | File Templates.
 */

class ModeleNews extends ModelePDO
{
    public static function getLesNews()
    {
        return ModelePDO::getLesTuples("news");
    }

    public static function getLesNewsLimit($debut, $fin)
    {
        return ModelePDO::getLesTuplesLimit('news', $debut, $fin);
    }

    public static function deleteNewsByID($id)
    {
        ModelePDO::deleteTuplesByChamp("news", "id", $id);
    }

    public static function updateNewsByID($id, $titre, $texte)
    {
        ModelePDO::updateTuplesByChamp('news', array('titre', 'texte'), array($titre, $texte), 'id', $id);
    }

    public static function insertNews($titre, $texte, $dateBDDInsertion)
    {
        $id = ModelePDO::genererClePrimaire('news', 'id');
        ModelePDO::insertTuple('news', array($id, $titre, $texte, $dateBDDInsertion));
        return $id;
    }

    public static function getNbNews()
    {
        return ModelePDO::getNbTuples('news');
    }
}